<template>
	<div>
		<div v-for="item of shopList">
			<button @click="changeValue( item.id, '-' )" :disabled="item.count===0">-</button>
			<span>{{ item.count }}</span>
			<button @click="changeValue(item.id, '+' )">+</button>
		</div>
		<p>totals：{{ $store.getters.totals }}</p>
	</div>
</template>
<script>
	export default {
		// 改变数据状态，需要提交 mutations 通过 commit
		name : 'self',
		computed : {
			shopList(){
				return this.$store.state.shopList
			},
			// totals(){
			// 	return this.$store.totals;
			// }
		},
		methods : {
			changeValue( id, flag ){
				this.$store.commit('updateCountById',{id,flag});
			},
			
		}

	}
</script>